﻿using UnityEngine;

public static partial class Extensions
{
    /// <summary>
    /// 将对象输出到日志
    /// </summary>
    public static T Log<T>(this T obj, LogMode logMode = LogMode.Log, bool formated = false)
    {
#if UNITY_EDITOR
        var msg = obj.ToJson(formated);
        switch (logMode)
        {
            case LogMode.Error:
                Debug.LogError(msg);
                break;

            case LogMode.Warning:
                Debug.LogWarning(msg);
                break;

            case LogMode.Log:
            default:
                Debug.Log(msg);
                break;
        };
#endif
        return obj;
    }
}

public enum LogMode
{
    Log,
    Warning,
    Error
}